home *** CD-ROM | disk | FTP | other *** search
- /* NAME:
- SysError.c
-
- WRITTEN BY:
- Dair Grant,
- Avi Drissman
-
- DESCRIPTION:
- This file contains a code resource to be installed as a Trap Patch.
-
- NOTES:
- We are applied as a patch to SysError, and cause force-quitting to not
- affect a screen saver.
-
- ___________________________________________________________________________
- */
- //=============================================================================
- // Include files, define stuff
- //-----------------------------------------------------------------------------
-
- //#define DEBUGGING_BUILD 1
-
- #include <Gestalt.h>
- #include "A4Stuff.h"
- #include "SetupA4.h"
- #include "bADs Constants.h"
- #include "ES Address Table.h"
- #include <Assembler.h>
- #include "AfterDarkGestalt.h"
-
-
- //=============================================================================
- // Types
- //-----------------------------------------------------------------------------
-
-
- //=============================================================================
- // Global Variables
- //-----------------------------------------------------------------------------
-
-
- //=============================================================================
- // Private function prototypes
- //-----------------------------------------------------------------------------
- asm void main(void);
-
-
- //=============================================================================
- // main : Entry point to our code resource.
- //-----------------------------------------------------------------------------
- // Note : We check to see if we should allow the force quit.
- //-----------------------------------------------------------------------------
- asm void main(void)
- {
- cmp.w #kForceQuit, d0 //Force quit?
- bne.s callThru //Never mind, then.
-
- movem.l a0-a5/d0-d7, -(a7) //Save the registers
- move.l #gestaltScreenSaverAttr, d0
- _Gestalt
- cmp.w #noErr, d0 //Error?
- beq.s isScreenSaver
- movem.l (a7)+, a0-a5/d0-d7 //Pull registers
- bra.s callThru
-
- isScreenSaver:
- move a0, d0 //Damn, can't bit-test a0
- btst #gestaltSaverAsleep, d0 //Are we screen saving?
- bne.s areSaving
- movem.l (a7)+, a0-a5/d0-d7 //Pull registers
- bra.s callThru
-
- areSaving:
- movem.l (a7)+, a0-a5/d0-d7 //Pull registers
- rts //Cancel force-quit
-
- callThru:
- movem.l a0/a2-a5/d0-d7, -(a7) //Save the registers
- move.l #kbADsAddressTable, d0
- _Gestalt //Where do we go?
- move.l a0, a1
- movem.l (a7)+, a0/a2-a5/d0-d7 //Pull registers
- addq.l #8, a1
- addq.l #4, a1 //Find where to go
- move.l (a1), -(sp) //Jump!
- rts
-
- }
-